﻿using System.Collections.Generic;
using UnityEngine;

namespace TC
{
    public class And : VariableNode
    {
        public List<ValueInput<bool>> items = null;
        public ValueOutput<bool> value;

        public override void OnCreate()
        {
            base.OnCreate();
            
            items = new List<ValueInput<bool>>();
            value = this.AddValueOutPort<bool>("value", () =>
            {
                if (items.Count <= 0) return default;

                bool tmp = items[0].Value;
                for(int i = 1; i < items.Count; ++i)
                {
                    tmp = tmp && items[i].Value;
                }
                return tmp;
            });
        }
    }
}
